cmake_minimum_required(VERSION 2.6)
PROJECT(testapp)
ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations)

FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)

SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
SET(SOURCES	testapp2.c)

ADD_EXECUTABLE(testapp ${SOURCES})

find_path(CAPI_INCLUDE_DIR capi-app-mgr.h
	HINTS ${STAGING_DIR}/usr/include)

find_library(CAPI_LIBRARY NAMES capi
	HINTS ${STAGING_DIR}/usr/lib)

find_path(UBOX_INCLUDE_DIR libubox/ustream.h
	HINTS ${STAGING_DIR}/usr/include)
find_library(UBOX_LIBRARY NAMES ubox
	HINTS ${STAGING_DIR}/usr/lib)	

INCLUDE_DIRECTORIES(${CAPI_INCLUDE_DIR} ${UBOX_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(testapp ${CAPI_LIBRARY})

find_path(GLIB_INCLUDE_DIR glib.h
	HINTS ${STAGING_DIR}/usr/include/glib-2.0)

find_library(GLIB_LIBRARY NAMES glib-2.0
	HINTS ${PC_GLIB_LIBDIR} ${PC_GLIB_LIBRARY_DIRS})

find_path(GIO_INCLUDE_DIR gio/gio.h
	HINTS ${STAGING_DIR}/usr/include/glib-2.0)

find_library(GIO_LIBRARY NAMES gio-2.0
	HINTS ${PC_GIO_LIBDIR} ${PC_GIO_LIBRARY_DIRS})

find_library(GMODULE_LIBRARY NAMES gmodule-2.0
	HINTS ${PC_GMODULE_LIBDIR} ${PC_GMODULE_LIBRARY_DIRS})

find_path(GOBJECT_INCLUDE_DIR gio/gio.h
	HINTS ${STAGING_DIR}/usr/include/glib-2.0)

find_library(GOBJECT_LIBRARY NAMES gobject-2.0
	HINTS ${PC_GOBJECT_LIBDIR} ${PC_GOBJECT_LIBRARY_DIRS})
	
INCLUDE_DIRECTORIES(${GOBJECT_INCLUDE_DIR} ${GIO_INCLUDE_DIR} ${GLIB_INCLUDE_DIR} )
TARGET_LINK_LIBRARIES(testapp ${GOBJECT_LIBRARY} ${GMODULE_LIBRARY} ${GIO_LIBRARY} ${GLIB_LIBRARY})


find_library(FFI_LIBRARY NAMES ffi
	HINTS ${PC_FFI_LIBDIR} ${PC_FFI_LIBRARY_DIRS})

find_library(Z_LIBRARY NAMES z
	HINTS ${PC_Z_LIBDIR} ${PC_Z_LIBRARY_DIRS})
	

TARGET_LINK_LIBRARIES(testapp ${FFI_LIBRARY} ${CAP_LIBRARY} ${Z_LIBRARY} ${UBOX_LIBRARY})
INSTALL(TARGETS testapp RUNTIME DESTINATION bin)
